package com.example.showactivity;

import java.util.ArrayList;

import com.example.funapp.*;


import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class SearchAdapter extends BaseAdapter {

	private Context context;
	private ArrayList<SearchData> arrData;
	private LayoutInflater inflater;

	public SearchAdapter(Context c, ArrayList<SearchData> arr) {
		this.context = c;
		this.arrData = arr;
		inflater = (LayoutInflater) c
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}

	public int getCount() {
		return arrData.size();
	}

	public Object getItem(int position) {
		return arrData.get(position).getTitle();
	}

	public long getItemId(int position) {
		return position;
	}

	public View getView(int position, View convertView, ViewGroup parent) {

		if (convertView == null) {
			convertView = inflater.inflate(R.layout.search_list_layout, parent, false);
		}

		TextView name = (TextView) convertView.findViewById(R.id.title);
		name.setText(arrData.get(position).getTitle());

		TextView tel = (TextView) convertView.findViewById(R.id.grade);
		tel.setText(arrData.get(position).getGrade());

		TextView email = (TextView) convertView.findViewById(R.id.place);
		email.setText(arrData.get(position).getPlace());


		return convertView;
	}

}
